package hbase

import hbase.HBaseUtils.{closeConnection, createTable, dropTable, isTableExists}
import org.apache.spark.{SparkConf, SparkContext}

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: libobo
 * @Date: 2021/09/28/下午4:17
 * @Description:
 */

object HbaseTest {
  def main(args: Array[String]): Unit = {

    // 创建表
    println("-----正在创建表-----")
    var tableName = "stu"
    var columnFamilies = Array[String]("class1")
    createTable(tableName, columnFamilies)
    var hbaseUtils = new HBaseUtils(tableName)
    println("-----查询表-----")

    println("-----正在插入数据-----")
   // 插入数据
    hbaseUtils.insertTable("libo", "class1", "age", "18")
    hbaseUtils.insertTable("libo", "class1", "sex", "man")
    hbaseUtils.insertTable("libo", "class1", "score", "100")
    hbaseUtils.insertTable("libo", "class1", "from", "Shanxi")
    hbaseUtils.insertTable("Zhansan", "class1", "age", "19")

    hbaseUtils.insertTable("Zhangss", "class1", "age", "25")
    hbaseUtils.insertTable("Zhangss", "class1", "sex", "man")
    hbaseUtils.insertTable("Zhangss", "class1", "score", "60")
    hbaseUtils.insertTable("Zhangss", "class1", "from", "Anhui")

//      // 删除数据
//      println("-----正在删除数据-----")
//      hbaseUtils.scanDataFromHTable("cf1","age")
//      hbaseUtils.deleteRecord("ZhangSan","cf1","age")
//      hbaseUtils.scanDataFromHTable("cf1","age")
//
//      // 删除表
//      println("查询表是否存在： "+ isTableExists(tableName))
//      dropTable(tableName)
//      println("查询表是否存在： "+ isTableExists(tableName))

    closeConnection()
  }
}